home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / demo1.zoo / demo / tests / many.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-24  |  1.6 KB  |  63 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: many.c,v 4.1 88/06/21 14:02:06 bianchi Exp $
  9.     $Source: /tmp/mgrsrc/demo/tests/RCS/many.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/demo/tests/RCS/many.c,v $$Revision: 4.1 $";
  12.  
  13. /* test many windows */
  14.  
  15. #include <stdio.h>
  16. #include "term.h"
  17.  
  18. #define GAP    10
  19.  
  20. main(argc,argv)
  21. int argc;
  22. char **argv;
  23.  
  24.    {
  25.    int num;
  26.    int count;
  27.    int x,y,w,h;
  28.    int lastx=0, lasty=0;
  29.    char buff[100];
  30.    char *sprintf();
  31.    int offset, foo;
  32.    register int i;
  33.    
  34.    if (argc < 2 || (count=atoi(argv[1])) <=0)
  35.       count = 5;
  36.  
  37.    srandom(getpid());
  38.    m_setup(M_FLUSH);
  39.    get_size(&x,&y,&w,&h);
  40.    foo = (w + h)/2;
  41.  
  42.    for(i=0;i<=count;i++) {
  43.       offset = random()%foo;
  44.       x += random()&1 ? offset+GAP : - (offset+GAP);
  45.       offset = random()%foo;
  46.       y += random()&1 ? offset+GAP : - (offset+GAP);
  47.       if (x<8) x=8;
  48.       if (y<80) y=80;
  49.       if (x+w > 1140) x = 1140-w;
  50.       if (y+h > 890) y = 890-w;
  51.       if (lastx == x || lasty == y) {
  52.          i--; continue;
  53.          }
  54.       lastx = x, lasty = y;
  55.       num = m_makewindow(x,y,w,h);
  56.       m_selectwin(num);
  57.       printf("Window %d\n",num);
  58.       } 
  59.    m_selectwin(0);
  60.    m_setmode(M_ACTIVATE);
  61.    printf("back to window zero\n");
  62.    }
  63.